package com.yt.lxh.acl.controller;

import com.yt.lxh.acl.service.RoleMenuService;
import com.yt.lxh.common.result.Result;
import com.yt.lxh.common.result.ResultCodeEnum;
import com.yt.lxh.dto.menu.AssignMenuDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping(value = "/admin/acl/roleMenu")
public class RoleMenuController {
    @Autowired
    private RoleMenuService roleMenuService;
    //1 查询所有菜单 和 查询角色分配过菜单id列表
    @GetMapping("/findRoleMenuByRoleId/{roleId}")
    public Result findRoleMenuByRoleId(@PathVariable("roleId") Integer roleId){
        Map<String,Object> map = roleMenuService.findSysRoleMenuByRoleId(roleId);
        return Result.build(map, ResultCodeEnum.SUCCESS);
    }

    //2 保存角色分配菜单数据
    @PostMapping("/doAssign")
    public Result doAssign(@RequestBody AssignMenuDto assignMenuDto){
        roleMenuService.doAssign(assignMenuDto);
        return Result.build(null, ResultCodeEnum.SUCCESS);
    }
}
